﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ImbaTracker.Models.Project>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Projects
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Projects</h2>

    <p>
        <% if (User.IsInRole("Administrator")) { %>
        <%: Html.ActionLink("Create New", "Create")%>
        <% } %>
    </p>

    <table>
        <tr>
            <th></th>
            <th> Id </th>
            <th> ProjectName </th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr>
            <td>
                
                <% if (User.IsInRole("Administrator") ||
                        ImbaTracker.Content.Helper.isProjectOwner(ImbaTracker.Content.Helper.curUserId(User), item.Id)) { %>
                <%: Html.ActionLink("Edit", "Edit", new { id=item.Id }) %> |
                <% } %>
                <%: Html.ActionLink("Details", "Details", item)%> |
                <% if (User.IsInRole("Administrator") ||
                        ImbaTracker.Content.Helper.isProjectOwner(ImbaTracker.Content.Helper.curUserId(User), item.Id)) { %>
                <%:   Html.ActionLink("Delete", "Delete", new { id = item.Id })%>
                <% } %>
                <% if (User.IsInRole("Administrator") ||
                        ImbaTracker.Content.Helper.isProjectMember(ImbaTracker.Content.Helper.curUserId(User), item.Id)) { %>
                <%:   Html.ActionLink("Add Issue", "AddIssue", new { id = item.Id })%>
                <% } %>
            </td>
            <td>
                <%: item.Id %>
            </td>   
            <td>
                <%: item.Name %>
            </td>
           
        </tr>
    
    <% } %>

    </table>

</asp:Content>

